import React from 'react';

export default class Index extends React.Component {
    constructor(props){
        super(props)
        this.state={
            data: [],
            system: [],
        }
    }
	componentDidMount(){
        document.title = '消息'
        global.Ajax.hhtc_request("notice/notice_list",{}).then(data=>{
			if(data.code===1){
				this.setState({
                    data: data.data.data,
                    system: data.data.system,
                })
			}
		})
	}
	render(){
		return(
			<div className='msg_list_box'>
                <div className='row' onClick={()=>{
                    this.props.history.push('/page/home/home/msgdetail')
                }}>
                    <img alt='' src={require('../../imgs/msg1.png')} className='icon' />
                    <div className='right'>
                        <div className='top'>
                            <p className='p1'>系统消息</p>
                            <p className='time'>{this.state.system.atime}</p>
                        </div>
                        <p className='desc'>{this.state.system.content}</p>
                    </div>
                </div>
                {this.state.data.map((item,index)=>{
                    return(
                        <div key={'list'+index} className='row'>
                            <img alt='' src={item.avatar} className='icon' />
                            <div className='right'>
                                <div className='top'>
                                    {item.type===1&&<p className='p1'>{item.nickname}<span>赞了你</span></p>}
                                    {item.type===2&&<p className='p1'>{item.nickname}<span>评论了你</span></p>}
                                    {item.type===3&&<p className='p1'>{item.nickname}<span>打赏了你</span></p>}
                                    {item.type!==1&&<p className='time'>{item.atime}</p>}
                                </div>
                                {item.type===1&&<p className='desc'>{item.atime}</p>}
                                {item.type===2&&item.content!=''&&<p className='desc'>{item.content}</p>}
                                {item.type===3&&<p className='das'><img alt='' src={require('../../imgs/hua.png')} />{item.num*1}朵</p>}
                            </div>
                        </div>
                    )
                })}
                {/* <div className='row'>
                    <img alt='' src={require('../../imgs/head.png')} className='icon' />
                    <div className='right'>
                        <div className='top'>
                            <p className='p1'>小姐姐<span>评论了你</span></p>
                            <p className='time'>02-12 15:00</p>
                        </div>
                        <p className='desc'>小红圈啊，小南泉，我在这里摸鱼哦~</p>
                    </div>
                </div>
                <div className='row'>
                    <img alt='' src={require('../../imgs/head.png')} className='icon' />
                    <div className='right'>
                        <div className='top'>
                            <p className='p1'>小姐姐<span>赞了你</span></p>
                        </div>
                        <p className='desc'>02-12 15:00</p>
                    </div>
                </div>
                <div className='row'>
                    <img alt='' src={require('../../imgs/head.png')} className='icon' />
                    <div className='right'>
                        <div className='top'>
                            <p className='p1'>小姐姐<span>打赏了你</span></p>
                            <p className='time'>02-12 15:00</p>
                        </div>
                        <p className='das'><img alt='' src={require('../../imgs/hua.png')} />10朵</p>
                    </div>
                </div> */}
			</div>
		)
	}
}
